/*     */ package com.newcrm.webapi.sub;
/*     */ 
/*     */ import com.newcrm.bean.User;
/*     */ import com.newcrm.db.DealManager;
/*     */ import com.newcrm.exception.DBException;
/*     */ import com.newcrm.exception.NotFoundException;
/*     */ import com.newcrm.util.Util;
/*     */ import com.newcrm.webapi.AbstractHttpServlet;
/*     */ import java.io.IOException;
/*     */ import java.io.PrintWriter;
/*     */ import java.util.ArrayList;
/*     */ import java.util.List;
/*     */ import javax.servlet.ServletException;
/*     */ import javax.servlet.http.HttpServletRequest;
/*     */ import javax.servlet.http.HttpServletResponse;
/*     */ import net.sf.json.JSONObject;
/*     */ import org.apache.log4j.Logger;
/*     */ 
/*     */ public class UpdateDeal extends AbstractAddUpdateCustomerDeal
/*     */ {
/*  32 */   private static Logger logger = Logger.getLogger(UpdateDeal.class.getName());
/*     */ 
/*  34 */   private int id = 0;
/*     */ 
/*     */   public UpdateDeal(AbstractHttpServlet servlet) {
/*  37 */     super(servlet);
/*     */   }
/*     */ 
/*     */   public UpdateDeal(AbstractHttpServlet servlet, String id) {
/*  41 */     super(servlet);
/*  42 */     this.id = Util.str2Int(id);
/*     */   }
/*     */ 
/*     */   public void parse(HttpServletRequest request, HttpServletResponse response)
/*     */     throws IOException, ServletException, NotFoundException
/*     */   {
/*  48 */     response.setContentType("text/html;charset=utf-8");
/*  49 */     PrintWriter out = response.getWriter();
/*  50 */     JSONObject jsonObject = new JSONObject();
/*     */ 
/*  52 */     User loginUser = super.getLoginUser(request);
/*  53 */     int dealStatus = Util.getURLIntParameter(request
/*  54 */       .getParameter("DealStatus"));
/*     */ 
/*  56 */     String dealName = 
/*  57 */       Util.getURLParameter(request.getParameter("DealName"));
/*     */ 
/*  59 */     if (dealStatus > 0)
/*     */     {
/*  61 */       DealManager manager = new DealManager();
/*     */       try {
/*  63 */         manager.updateDealStatus(this.id, dealStatus, dealName, 
/*  64 */           loginUser.userId, loginUser.companyId);
/*  65 */         jsonObject.put("error", "0");
/*     */       } catch (Exception e) {
/*  67 */         e.printStackTrace();
/*  68 */         jsonObject.put("error", "1");
/*     */       }
/*  70 */       out.println(jsonObject);
/*  71 */       out.flush();
/*  72 */       out.close();
/*  73 */       return;
/*     */     }
/*     */ 
/*  76 */     String userId = loginUser.userId;
/*  77 */     String userName = loginUser.name;
/*  78 */     int companyId = loginUser.companyId;
/*     */ 
/*  80 */     int customerId = Util.getURLIntParameter(request
/*  81 */       .getParameter("customerId"));
/*  82 */     String customerName = Util.getURLParameter(request
/*  83 */       .getParameter("customerName"));
/*  84 */     int customerType = Util.getURLIntParameter(request
/*  85 */       .getParameter("customerType"));
/*     */ 
/*  87 */     String name = Util.getURLParameter(request.getParameter("dealName"));
/*     */ 
/*  89 */     String note = Util.getURLParameter(request.getParameter("background"));
/*     */ 
/*  91 */     float price = Util.getURLFloatParameter(request.getParameter("price"));
/*     */ 
/*  93 */     float commission = Util.getURLFloatParameter(request
/*  94 */       .getParameter("commission"));
/*     */ 
/*  96 */     int categoryId = Util.getURLIntParameter(request
/*  97 */       .getParameter("categoryId"));
/*     */ 
/* 100 */     String responsibleUserId = Util.getURLParameter(request
/* 101 */       .getParameter("responsibleUserId"));
/*     */ 
/* 103 */     List extInfos = new ArrayList();
/*     */ 
/* 105 */     super.addFieldInfo(request, extInfos);
/*     */ 
/* 107 */     DealManager manager = new DealManager();
/*     */     try {
/* 109 */       manager.update(this.id, customerId, customerName, customerType, 
/* 110 */         name, note, categoryId, responsibleUserId, price, 
/* 111 */         commission, extInfos, companyId, userId, userName);
/*     */     }
/*     */     catch (DBException e) {
/* 114 */       logger.warn("update deal failed", e);
/*     */     }
/* 116 */     response.sendRedirect(request.getContextPath() + "/deals/" + this.id);
/*     */   }
/*     */ }

/* Location:           C:\E\referenceProject\CRM参考\qikebao\WEB-INF\lib\qikebao.jar
 * Qualified Name:     com.newcrm.webapi.sub.UpdateDeal
 * JD-Core Version:    0.6.1
 */